// https://www.acwing.com/problem/content/11/

#include <iostream>
#include <vector>
using namespace std;

const int MOD = 1e9 + 7;

pair<int, int> knapsack(const vector<int>& weights, const vector<int>& values, int W) {
    int n = weights.size();
    vector<int> dp_value(W + 1, 0);
    vector<int> dp_count(W + 1, 0);
    dp_count[0] = 1;

    for (int i = 0; i < n; ++i) {
        for (int j = W; j >= weights[i]; --j) {
            if (dp_value[j - weights[i]] + values[i] > dp_value[j]) {
                dp_value[j] = dp_value[j - weights[i]] + values[i];
                dp_count[j] = dp_count[j - weights[i]];
            } else if (dp_value[j - weights[i]] + values[i] == dp_value[j]) {
                dp_count[j] = (dp_count[j] + dp_count[j - weights[i]]) % MOD;
            }
        }
    }

    return {dp_value[W], dp_count[W]};
}

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> values(n), weights(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &weights[i], &values[i]);
    }

    auto result = knapsack(weights, values, W);
    printf("%d\n", result.second);

    return 0;
}
